const OperateType = {
  None : 0,
  Create : 1,
  Edit : 2,
  Save : 3
}

function getFormatTime(){
  const date = new Date()
  const y = date.getFullYear()
  const m = formatZero(date.getMonth() + 1)
  const d = formatZero(date.getDate())
  const h = formatZero(date.getHours())
  const mm = formatZero(date.getMinutes())
  const s = formatZero(date.getSeconds())
  return `${y}-${m}-${d}-${h}-${mm}-${s}`
}

function formatZero(val){
  return val < 10 ? '0' + val : val;
}

function randomInt(min,max){
  return Math.floor(Math.random() * (max-min + 1) + min)
}

const seed = {
  min:10000,
  max:99999
}

function genrateId(){
  const time = getFormatTime()
  const r = randomInt(seed.min,seed.max)
  return `${time}+${r}`
}

export {OperateType,randomInt,getFormatTime,genrateId}